<template>
  <div class="active-model" @click.self="closeActive">
    <div class="in-active-model">
      <i class="close" @click.self="closeActive">×</i>
      <h1>活动中心-{{ mapName }}</h1>
      <ul>
        <li v-for="(item, index) in obj.lts" v-bind:key="index">
          <div class="icon-tip" v-show="currid == item.active_id"></div>
          <p>{{ item.str_ed_time }}结束</p>
          <h4>
            【{{
              item.active_type == 1
                ? "抽奖活动"
                : item.active_type == 3
                ? "通行证活动"
                : item.active_type == 2
                ? "优惠券活动"
                : ""
            }}】 {{ item.active_title }}
          </h4>
          <a
            v-bind:href="
              'qfyygame:///type=web_action/?action_type=2&web_url=' +
              item.url +
              '&login_mode=2'
            "
            class="ljcy"
            >立即参与</a
          >
        </li>
      </ul>
    </div>
  </div>
</template>
<script setup>
import { ref, toRefs, reactive, defineProps, watch, defineEmits, computed } from "vue"
import _service from "../service/index"
import { useStore } from "vuex"
let { getters } = useStore()
const mapName = ref("")
const currid = computed(() => getters["user/act_id"])
const obj = reactive({ lts: [] })
const props = defineProps({
  map_id: {
    type: Number,
  },
  map_name: {
    type: String,
  },
})

watch(
  [() => props.map_id, () => props.map_name],
  (newValue, oldValue) => {
    console.log("值发生了变更", newValue, oldValue)
    mapName.value = newValue[1]
    GetAllActivity(newValue[0])
  },
  { deep: true, immediate: true }
)

async function GetAllActivity (mid) {
  const res = await _service.GetAllActivity(mid)
  console.log(22, res)
  if (res.errCode == 0) {
    obj.lts = res.data
  }
}
const emit = defineEmits(["closeActive"])
const closeActive = () => {
  emit("closeActive")
};
</script>

<style lang="scss" >
.active-model {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
  .in-active-model {
    width: 737px;
    height: 526px;
    background: url(@/assets/images/active-center.png);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    .close {
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      position: absolute;
      top: 3px;
      right: 15px;
      color: #fff;
      font-size: 18px;
      font-weight: bold;
      cursor: pointer;
    }
    h1 {
      width: 412px;
      position: absolute;
      top: 18px;
      left: 50%;
      transform: translateX(-50%);
      text-align: center;
      font-size: 24px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: #ffffff;
    }
    ul {
      width: 685px;
      height: 350px;
      overflow-y: auto;
      overflow-x: hidden;
      position: absolute;
      top: 100px;
      left: 50%;
      transform: translateX(-50%);
      li {
        width: 647px;
        height: 67px;
        background: url(@/assets/images/active-li.png);
        margin-bottom: 10px;
        padding: 17px 0px 0px 38px;
        position: relative;
        display: flex;
        flex-direction: column;
        flex-wrap: wrap;
        justify-self: flex-start;
        p {
          font-size: 14px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #3b9be5;
        }
        h4 {
          font-size: 18px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          color: #1b435d;
          word-spacing: 0;
        }
        .icon-tip {
          width: 21px;
          height: 81px;
          background: url(@/assets/images/icon-tips.png);
          position: absolute;
          top: 0px;
          left: 0px;
        }
        .ljcy {
          width: 97px;
          height: 27px;
          line-height: 27px;
          text-align: center;
          background: #ffb44e;
          border-radius: 5px;
          font-size: 14px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #ffffff;
          position: absolute;
          top: 50%;
          transform: translateY(-50%);
          right: 50px;
        }
      }
    }
  }
}
</style>